//
//  SISSMyBrokerageHeaderView.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/4/8.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSMyBrokerageHeaderView.h"


@interface SISSMyBrokerageHeaderView ()

/// 账户余额
@property (weak, nonatomic) UILabel *accountTitleLabel;
/// 账户金额
@property (weak, nonatomic) UILabel *accountLabel;
/// 冻结金额label
@property (weak, nonatomic) UILabel *accountFrozenLabel;
/* <#Annotation#> */
@property (weak, nonatomic) UIButton *button;

@end
@implementation SISSMyBrokerageHeaderView

- (void)setAccountMoney:(NSString *)accountMoney {
    _accountMoney = accountMoney;
    self.accountLabel.text =  [NSString stringWithFormat:@"￥%@",accountMoney ? accountMoney : @"0.00"];
}

- (void)setAccountFrozenMoney:(NSString *)accountFrozenMoney {
    _accountFrozenMoney = accountFrozenMoney;
    self.accountFrozenLabel.text = [NSString stringWithFormat:@"其中冻结金额：￥%@",accountFrozenMoney ? accountFrozenMoney : @"0.00"];
}

- (void)buttonClickAction {
    [self alertActionAlertWithTitle:@"冻结金额" message:@"为了保障交易各方的利益，首期款金额需在承租方确认入住或租赁起始日期七天后才能解冻提现。"];
}

- (void)initUI {
    [super initUI];
    
    self.backgroundColor = COLOR(0x54CD78);
    
    /// 账户余额
    UILabel *accountTitleLabel = [UILabel yyr_labelWithText:@"账户余额" fontSize:15 textColor:[UIColor whiteColor]];
    [self addSubview:accountTitleLabel];
    self.accountTitleLabel = accountTitleLabel;
    
    /// 账户金额
    UILabel *accountLabel = [UILabel yyr_labelWithText:@"￥0.00" fontSize:32 textColor:[UIColor whiteColor]];
    [self addSubview:accountLabel];
    self.accountLabel = accountLabel;
    
    /// 冻结金额
    UILabel *accountFrozenLabel = [UILabel yyr_labelWithText:@"其中冻结金额：￥ 0.00" fontSize:13 textColor:[UIColor whiteColor]];
    [self addSubview:accountFrozenLabel];
    self.accountFrozenLabel = accountFrozenLabel;
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"?-anz"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    self.button = button;
}

- (void)initConstraint {
    [super initConstraint];
    
    CGFloat margin = 8.0;
    [self.accountTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(2 * margin);
        make.top.equalTo(self).offset(2 * margin + kTopHeight);
    }];
    
    [self.accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(2 * margin);
        make.top.equalTo(self.accountTitleLabel.mas_bottom).offset(2 * margin);
    }];
    
    [self.accountFrozenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(2 * margin);
        make.top.equalTo(self.accountLabel.mas_bottom).offset(2 * margin);
        make.bottom.equalTo(self).offset(-2 * margin);
    }];
    
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.accountFrozenLabel.mas_right).offset(margin);
        make.centerY.equalTo(self.accountFrozenLabel);
    }];
}

@end
